package com.authstr.fitness_room_manage.controller;

import com.authstr.fitness_room_manage.service.inter.JsfMemberService;
import com.authstr.model.jsf.JsfMemberInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.authstr.basic.reqres.request.RequestPara;
import com.authstr.basic.reqres.response.ResponseData;
import com.authstr.basic.web.controller.AbstractController;
import com.authstr.model.base.BaseMenu;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@RequestMapping("jsf_member")
@RestController
public class JsfMemberController extends AbstractController {

    @Autowired
    JsfMemberService jsfMemberService;

    @RequestMapping("query")
    public ResponseData query(@Param("page") Page page, String name) {
        Page page1= jsfMemberService.query(page);
        return ResponseData.success(page1);
    }

    @RequestMapping("add_or_edit")
    public ResponseData add_or_edit(@Valid JsfMemberInfo model) {
        return ResponseData.success(jsfMemberService.addOrEdit(model));
    }

    @RequestMapping("setMemberUserId")
    public ResponseData setMemberUserId(String id,Long user_id) {
        return ResponseData.success(jsfMemberService.setMemberUserId(id,user_id),null);
    }



    @RequestMapping("delete")
    public ResponseData delete(Long[] ids) {
        jsfMemberService.delete(ids);
        return ResponseData.success();
    }

    @RequestMapping("delete_chilren")
    public ResponseData delete_chilren(Integer[] ids) {
//        jsfMemberService.delete(ids);
        return ResponseData.success();
    }


    @RequestMapping("getAll")
    public ResponseData getAll(HttpServletRequest request) {
        RequestPara para= new RequestPara(request);
        return ResponseData.success(jsfMemberService.getAll(para));
    }

    @RequestMapping("getById")
    public ResponseData getById( Integer id) {
        return ResponseData.success(jsfMemberService.getById(id));
    }

    @RequestMapping("getMenuIdByRoleId")
    public ResponseData getMenuIdByRoleId(Long roleId) {
        return ResponseData.success();
    }

}

